Release 10.1A: OpenEdge Application Server:
Developing WebSpeed Applications


get-transaction-state

This procedure returns the current database transaction state for the agent as the procedure’s RETURN-VALUE. The six possible values are: ‘NONE’, ‘ACTIVE’, ‘START-PENDING’, ‘UNDO-PENDING’, ‘RETRY-PENDING’, and ‘COMMIT-PENDING’.

Location: web\objects\web-util.p

Parameters: None

Returns: CHARACTER

Notes:

The first example checks the transaction state before a database transaction starts. In this case, the Web object starts a new transaction whether or not one already exists, as shown:

RUN get-transaction-state IN web-utilities-hdl.
IF RETURN-VALUE eq 'NONE':U THEN
  RUN set-transaction-state IN web-utilities-hdl (‘START’:U).
ELSE IF RETURN-VALUE eq ‘ACTIVE’:U THEN
  RUN set-transaction-state IN web-utilities-hdl (‘RETRY’:U). 

The second example shows how to avoid running two Web objects, where both rely on database transactions. If there already is a transaction, an error message is generated. This is an important test because all requests to a WebSpeed agent run within the same transaction. A single UNDO button will undo the work done by all Web objects running on the same agent, as shown:

\* Report an error message if there is already an ACTIVE transaction. *\
RUN get-transaction-state IN web-utilities-hdl.
IF RETURN-VALUE eq 'UNDO':U THEN DO:
  \* OK to turn this object into a state-aware object
     using a DB TRANSACTION. *\
  setWebState(20.0).
  RUN set-transaction-state IN web-utilities-hdl (‘START’:U).
END.
ELSE DO:
  \* Don’t allow this object to start up
     because a DB TRANSACTION is active. *\
  RUN HtmlError IN web-utilities-hdl 
  ('Close the current database transaction before starting this web object.').
  RETURN.
END. 

See also:

set-transaction-state


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095